import requests
import json
import os
import datetime

from requests.api import patch


res = requests.post('http://127.0.0.1:5000/course/blogin',{"username":'sel',"password":'sel'})
print(res)
mes = json.loads(res.text)
print(mes)
flog = "通过"
if mes['code'] == 10011:
    flog = '不通过'

dict ={'请求地址':'','请求方式':'post','传递参数':'','测试结果':flog}
#以时间创建文件
filename = datetime.datetime.strftime(datetime.datetime.now(),'%Y%m%d')
with open(os.path.join('./logs/'+filename+'.txt'),'w',encoding='utf-8') as f:
    f.write(json.dumps(dict,ensure_ascii=False))
